Function: serialize

CALL:

DESCRIPTION:

Serialize a Matlab variable.

INPUT:

S any
matlab variable
ishex boolean
if false (default)
    return (1xN) uint8 byte array
if true:
    return (1xP) char array with elements in
    0123456789ABCDEF. P  = (approx) 2*N

OUTPUT:

byteData uint8[N,1]|char[P,1]
serialized form of S. Use deserialize to convert back.